package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.vo.Approval.analysis.DeptApprovalVO;
import com.ruoyi.system.domain.vo.Approval.analysis.MonthApprovalVO;
import com.ruoyi.system.domain.vo.Approval.analysis.TypeApprovalVO;
import com.ruoyi.system.service.IApprovalAnalysisOverviewService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/approval/analysis/overview")
public class ApprovalAnalysisOverviewController extends BaseController {
    @Autowired
    private IApprovalAnalysisOverviewService approvalAnalysisOverviewService;

    @GetMapping("/getApprovalCount")
    public AjaxResult getApprovalCount(@RequestParam(required = false) String status) {
        int count = approvalAnalysisOverviewService.getApprovalCount(status);
        return AjaxResult.success(count);
    }

    @GetMapping("/getMonthApprovalCountByYear")
    public TableDataInfo  getMonthApprovalCountByYear(@Param("year") String year) {
        List<MonthApprovalVO> list = approvalAnalysisOverviewService.getMonthApprovalCountByYear(year);
        return getDataTable(list);
    }

    @GetMapping("/getDeptApprovalCount")
    public TableDataInfo getDeptApprovalCount() {
        List<DeptApprovalVO> list = approvalAnalysisOverviewService.getDeptApprovalCount();
        return getDataTable(list);
    }

    @GetMapping("/getTypeApprovalCount")
    public TableDataInfo getTypeApprovalCount() {
        List<TypeApprovalVO> list = approvalAnalysisOverviewService.getTypeApprovalCount();
        return getDataTable(list);
    }
}
